package gold.digger;

import gold.utils.InputUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC1111 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int[] maxDepthAfterSplit(String seq) {
            int aGroupCount = 0, bGroupCount = 0;
            int[] res = new int[seq.length()];
            for (int i = 0; i < seq.length(); i++) {
                char c = seq.charAt(i);
                if ('(' == c) {
                    if (aGroupCount > bGroupCount) {
                        ++bGroupCount;
                        res[i] = 1;// b 组都认为是1
                    } else {
                        ++aGroupCount;
                    }
                } else {
                    if (aGroupCount > bGroupCount) {
                        --aGroupCount;
                    } else {
                        --bGroupCount;
                        res[i] = 1;// b 组都认为是1
                    }
                }
            }

            return res;
        }
    }

    public void run() {
        Solution solution = new Solution();
        System.out.println(solution.maxDepthAfterSplit("(()())"));
    }

    public static void main(String[] args) throws Exception {
        LC1111 an = new LC1111();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
